package com.sen;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@SpringBootApplication
public class ModuleApplication implements WebMvcConfigurer {

	public static void main(String[] args) {
		SpringApplication.run(ModuleApplication.class, args);
	}

	/**
	 * 视频路径
	 */
	@Value("${video-path}")
	private String videoPath;

	/**
	 * 图片路径
	 */
	@Value("${img-path}")
	private String imgPath;

	// 作用：把 url 路径和 磁盘路径做一个映射
	// http://localhost:8080/play/xxx => static/play
	// http://localhost:8080/play/xxx => d:/aaa
	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry){
		//       url 路径                                    磁盘路径
		registry.addResourceHandler("/part/**").addResourceLocations("file:" + videoPath);
		registry.addResourceHandler("/img/**").addResourceLocations("file:" + imgPath);
	}
}
